//author Gideon Beyrle
#ifndef GRAPHICS_H
#define GRAPHICS_H

#include <stdio.h>
#include <stdlib.h>
#include <vector>
#define GLEW_STATIC
// ACHTUNG: glew immer vor glfw includen!
#include <GL/glew.h>

#define GLFW_DLL
#include <GL/glfw.h>

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <math.h>

using namespace glm;
using namespace std;

#include "shader.hpp"
#include "VertexData.h"


 class graphics
{
    public:
        graphics();
        virtual ~graphics();
        void loadShaders();
        int field(GLfloat holeradius);
        int close();
        int open();
        int bowl(GLfloat xCoordinate, GLfloat yCoordinate, GLfloat rad, VertexData colorData);
        void sphere(GLfloat xCoord, GLfloat yCoord, GLfloat radius, VertexData colorData);

    private:
        vector<VertexData> vertexbufferData_BrownRectangle;
        vector<VertexData> colorbufferData_BrownRectangle;
        vector<VertexData> vertexbufferData_DarkgreenRectangle;
        vector<VertexData> colorbufferData_DarkgreenRectangle;
        vector<VertexData> vertexbufferData_GreenRectangle;
        vector<VertexData> colorbufferData_GreenRectangle;
        vector<VertexData> triangleVertices;
        vector<VertexData> sphereVertices;
        vector<VertexData> normals;
        int framerange = 60;
        VertexData oldmidpoint;
        bool created = false;
        mat4 MVP;
        GLuint programID2;
        GLuint programID;
        GLuint vertexArrayID;
        GLuint MatrixID;
        void init();
        void draw(vector<VertexData> vertexData,vector<VertexData> colorData, bool triangle);
        void draw(vector<VertexData> vertexData,vector<VertexData> colorData, vector<VertexData> normalData, bool triangle);
        void subdivide(VertexData a, VertexData b, VertexData c, long depth);
        VertexData normalize(VertexData a, VertexData b, GLfloat radius);
        VertexData normal(VertexData a, VertexData b, VertexData c);
};

#endif // GRAPHICS_H
